package com.example.demo.service.impl;

import java.util.Date;
import java.util.List;

import com.example.demo.entity.Icon;
import com.example.demo.mapper.IconMapper;
import com.example.demo.service.IIconService;
import com.example.demo.utils.PageResult;
import com.example.demo.utils.PageUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * iconService业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-03
 */
@Service
public class IconServiceImpl implements IIconService
{
    @Autowired
    private IconMapper iconMapper;

    /**
     * 查询icon
     * 
     * @param icid icon主键
     * @return icon
     */
    @Override
    public Icon selectIconByIcid(Long icid)
    {
        return  iconMapper.selectIconByIcid(icid);

    }

    @Override
    public PageResult IconGoodsList(Icon icon, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Icon> list =  iconMapper.IconGoodsList(icon);
        PageInfo<Icon> pageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return pageResult;
    }

    /**
     * 查询icon列表
     * 
     * @param icon icon
     * @return icon
     */
    @Override
    public List<Icon> selectIconList(Icon icon)
    {
        return  iconMapper.selectIconList(icon);
    }

    /**
     * 新增icon
     * 
     * @param icon icon
     * @return 结果
     */
    @Override
    public int insertIcon(Icon icon)
    {
        icon.setCreateTime(new Date());
        return iconMapper.insertIcon(icon);
    }

    /**
     * 修改icon
     * 
     * @param icon icon
     * @return 结果
     */
    @Override
    public int updateIcon(Icon icon)
    {
        icon.setUpdateTime(new Date());
        return iconMapper.updateIcon(icon);
    }

    /**
     * 批量删除icon
     * 
     * @param icids 需要删除的icon主键
     * @return 结果
     */
    @Override
    public int deleteIconByIcids(Long[] icids)
    {
        return iconMapper.deleteIconByIcids(icids);
    }

    /**
     * 删除icon信息
     * 
     * @param icid icon主键
     * @return 结果
     */
    @Override
    public int deleteIconByIcid(Long icid)
    {
        return iconMapper.deleteIconByIcid(icid);
    }
}
